﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using FrameworkLib.Utilities;
using ControlsLib;
using GestionePolveriLib.BL;
using GestionePolveriLib.Facades;
using Controlslib.Toolstrip;
using ControlsLib.Toolbars;

namespace GestionePolveri2
{
    /// <summary>
    /// 
    /// </summary>
    public class MainToolbar : MainFormToolbar
    {
        public MainToolbar() : base("MainToolbar")
        {
        }

        //public void AddComboTurni()
        //{
        //    TurniFacade tf = new TurniFacade();

        //    ToolStripComboBox cmb = CreaCombo("cmbTurni", "Turni");

        //    tf.LoadTurniAsync((result) =>
        //    {
        //        cmb.ComboBox.LoadData("Descrizione", "ID", result, new Turno() { Id = -1, Descrizione = "Seleziona..." });
        //    });
        //}

        //public void AddComboImpianti()
        //{
        //    ImpiantoFacade tf = new ImpiantoFacade();

        //    ToolStripComboBox cmb = CreaCombo("cmbImp", "Impianti");

        //    cmb.SelectedIndexChanged +=new EventHandler(cmb_SelectedIndexChanged);

        //    tf.RunAsync<List<Impianto>>(() => tf.GetImpianti(false), (result) =>
        //    {
        //        cmb.ComboBox.LoadData("Nome", "ID", result, new Impianto() { ID = -1, Nome = "Seleziona...", Fittizio = false });
        //    });

        //    //ElencoImpiantiEx impianti = new ElencoImpiantiEx();
        //    //impianti.Initialize();

        //    //ElencoImpiantiWrapper<ElencoImpiantiEx> d3 = new ElencoImpiantiWrapper<ElencoImpiantiEx>();
        //    //d3.Control.Initialize();
        //    //d3.OnEventOccurred += new EventHandler<HostableControlEvent>(d3_OnEventOccurred);
        //    //ToolStripDropDownButton tsddb = new ToolStripDropDownButton();

        //    //tsddb.Alignment = ToolStripItemAlignment.Right;
            
        //    //tsddb.DisplayStyle = ToolStripItemDisplayStyle.Text;
        //    //tsddb.Text = "Impianti";
        //    //tsddb.DropDown = d3;
        //    //this.Items.Add(tsddb);

        //}

        //public void AddComboImpiantiFittizi()
        //{
        //    ImpiantoFacade tf = new ImpiantoFacade();

        //    ToolStripComboBox cmb = CreaCombo("cmbImpFitt", "Impianti Fitt.");
        //    cmb.SelectedIndexChanged += new EventHandler(cmb_SelectedIndexChanged);

        //    tf.RunAsync<List<Impianto>>(() => tf.GetImpianti(true), (result) =>
        //    {
        //        cmb.ComboBox.LoadData("Nome", "ID", result, new Impianto() { ID=-1, Nome="Seleziona...", Fittizio=true });
        //    });
        //}

        void d3_OnEventOccurred(object sender, HostableControlEvent e)
        {
            
        }

        //void cmb_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    base.OnEventRaised(sender);
        //}

        public Turno Turno
        {
            get { return (Turno)((ToolStripComboBox)this.Items["cmbTurni"]).ComboBox.SelectedItem; }
        }
    }
}
